package com.hphs.controller;

import com.hphs.model.Product;
import com.hphs.model.ProductQuery;
import com.hphs.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("api/product")
@CrossOrigin
public class ProductController {

    //控制需要读取数据 数据在service里面
    @Autowired
    private ProductService service;
    //get 请求
    @GetMapping("/findAll")
    public List<Product> findAll(){
        List<Product> productList = service.findAll();
        return productList;
    }
    @GetMapping
    public List<Product> select(ProductQuery query){
        List<Product> productList = service.select(query);
        return productList;
    }
}
